Docker 安装及配置镜像加速的实现

您所在的位置:网站首页 配置docker 国内镜像源 Docker 安装及配置镜像加速的实现

Docker 安装及配置镜像加速的实现

2024-07-17 02:45:53| 来源: 网络整理| 查看: 265

狐狸嘿嘿 02-20 12:46 阅读 126 Docker 安装及配置镜像加速的实现 Docker 版本

  随着 Docker 的飞速发展,企业级功能的上线,更好的服务意味着需要支付一定的费用,目前 Docker 被分为两个版本:

community-edition 社区版

enterprise-edition 企业版

  Docker 企业版(EE)专为企业开发和 IT 团队设计,可在大规模生产中构建,运送和运行关键业务应用程序。Docker EE 集成,认证和支持,为企业提供业界最安全的容器平台,实现所有应用程序的现代化。作为一个以应用为中心的平台,Docker EE 旨在加速和保护整个软件供应链,从开发到在任何基础设施上运行的生产。

  我们学习 Docker 使用 CE 社区版即可。

在 CentOS 上安装 Docker 引擎

  Docker 支持 Mac Windows Linux,本文使用 Linux 环境教大家如何基于 CentOS 安装 Docker 及配置镜像加速。

  官方文档:https://docs.docker.com/

系统要求

  官网提示如果要安装 Docker Engine,您需要一个 CentOS 7 以及以上的稳定版本。

卸载旧版本

  较旧的 Docker 版本为 docker 或 docker-engine。 如果已安装这些程序,请卸载它们以及相关的依赖项。

12345678sudo yum remove docker \     docker-client \     docker-client-latest \     docker-common \     docker-latest \     docker-latest-logrotate \     docker-logrotate \     docker-engine

Docker 镜像、容器、数据卷和网络数据都保存在 /var/lib/docker/。新的 Docker 引擎包现在为 Docker-ce。

设置 yum 源

  安装 yum-utils 软件包(提供了 yum-config-manager 程序)并设置稳定的 yum 源方便下载 Docker Engine。

1234# 安装 yum-utilssudo yum install -y yum-utils# 设置 yum 源为阿里云方便下载 Docker Enginesudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoDocker 安装

  安装最新版本的 Docker Engine 和容器。

1sudo yum install docker-ce docker-ce-cli containerd.io

安装过程中如果提示您接受 GPG 密钥,请验证指纹是否与 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 匹配,如果是,请接受。

Docker 的启动与停止12345678910111213141516# 启动 dockersudo systemctl start docker# 停止 dockersudo systemctl stop docker# 重启 dockersudo systemctl restart docker# 设置开机启动sudo systemctl enable docker# 查看 docker 状态sudo systemctl status docker# 查看 docker 内容器的运行状态sudo docker stats# 查看 docker 概要信息sudo docker info# 查看 docker 帮助文档sudo docker --help安装校验123456789101112131415161718192021222324252627282930[root@localhost ~]# docker -vDocker version 19.03.12, build 48a66213fe[root@localhost ~]# docker versionClient: Docker Engine - Community Version:   19.03.12 API version:  1.40 Go version:  go1.13.10 Git commit:  48a66213fe Built:    Mon Jun 22 15:46:54 2020 OS/Arch:   linux/amd64 Experimental:  false Server: Docker Engine - Community Engine: Version:   19.03.12 API version:  1.40 (minimum version 1.12) Go version:  go1.13.10 Git commit:  48a66213fe Built:   Mon Jun 22 15:45:28 2020 OS/Arch:   linux/amd64 Experimental:  false containerd: Version:   1.2.13 GitCommit:  7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version:   1.0.0-rc10 GitCommit:  dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version:   0.18.0 GitCommit:  fec3683配置镜像加速

  Docker 从 Docker Hub 拉取镜像,因为是从国外获取,所以速度较慢,会出现以下情况:

1234[root@localhost ~]# docker run hello-worldUnable to find image 'hello-world:latest' locallydocker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: net/http: TLS handshake timeout.See 'docker run --help'.

  可以通过配置国内镜像源的方式,从国内获取镜像,提高拉取速度。这里介绍中国科学技术大学(LUG@USTC)的开源镜像:https://docker.mirrors.ustc.edu.cn 和网易的开源镜像:http://hub-mirror.c.163.com

  USTC 是老牌的 Linux 镜像服务提供者了,USTC 的 Docker 镜像加速服务速度很快。USTC 和网易的优势之一就是不需要注册,属于真正的公共服务。(也可以使用阿里等其他服务商的镜像加速服务)

  编辑文件 daemon.json 。

1vi /etc/docker/daemon.json

  在文件中输入以下内容并保存。

123{ "registry-mirrors": ["http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn"]}

  重新加载配置信息及重启 Docker 服务。

1234# 重新加载某个服务的配置文件sudo systemctl daemon-reload# 重新启动 dockersudo systemctl restart dockerhello-world

  通过运行 hello-world 镜像来验证 Docker Engine 是否已正确安装。

12345678910111213141516171819202122232425262728[root@localhost ~]# docker run hello-worldUnable to find image 'hello-world:latest' locally # 本地找不到 hello-world 镜像latest: Pulling from library/hello-world # 拉取最新版本的 hello-world 镜像0e03bdcc26d7: Pull complete Digest: sha256:49a1c8800c94df04e9658809b006fd8a686cab8028d33cfba2cc049724254202Status: Downloaded newer image for hello-world:latest # 看到此消息表示您已正常安装。Hello from Docker!This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/

  docker run hello-world 命令执行流程图如下。

通过以上步骤大家已完成 Docker 安装的所有工作,接下来通过学习镜像命令和容器命令更加熟悉 Docker 的使用。

到此这篇关于Docker 安装及配置镜像加速的实现的文章就介绍到这了



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭